/**
 * 初始化业务字典详情对话框
 */
var CdcDictionaryInfoDlg = {
    validateFields: {
    	code: {
            validators: {
                notEmpty: {
                    message: '代码不能为空'
                }
            }
        },
    	description: {
            validators: {
                notEmpty: {
                    message: '描述不能为空'
                }
            }
        },
    	dictypeId: {
            validators: {
                notEmpty: {
                    message: '字典类型不能为空'
                }
            }
        },
    	isActive: {
            validators: {
                notEmpty: {
                    message: '是否有效不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
CdcDictionaryInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
CdcDictionaryInfoDlg.validate = function () {
    $('#cdcDictionaryInfoForm').data("bootstrapValidator").resetForm();
    $('#cdcDictionaryInfoForm').bootstrapValidator('validate');
    return $("#cdcDictionaryInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
CdcDictionaryInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcDictionaryInfoForm',Sys.backendPath + "/cdc/cdcdictionary/add",function(res) {
        Sys.success(res.message);
    	window.parent.CdcDictionary.table.refresh();
        CdcDictionaryInfoDlg.close();
    });
}

/**
 * 提交修改
 */
CdcDictionaryInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcDictionaryInfoForm',Sys.backendPath + "/cdc/cdcdictionary/update",function(res) {
        Sys.success(res.message);
    	window.parent.CdcDictionary.table.refresh();
        CdcDictionaryInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("cdcDictionaryInfoForm", CdcDictionaryInfoDlg.validateFields);
    $("#dictypeId").combobox("disable");
    $("#dictypeId").combobox('setValue', window.parent.CdcDictionary.dictypeId);
});
